<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>DJI 无人机列表</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css">
    <style>
        .drone-card {
            transition: transform 0.2s;
            margin-bottom: 20px;
        }
        .drone-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 20px rgba(0,0,0,0.1);
        }
        .status-badge {
            font-size: 0.8rem;
            padding: 5px 10px;
        }
        .battery-indicator {
            height: 20px;
            border-radius: 3px;
            overflow: hidden;
        }
    </style>
</head>
<body>
    <div class="container mt-4">
        <header class="mb-4">
            <h1 class="text-center">DJI 无人机列表</h1>
            <p class="text-center text-muted">选择一架无人机进行监控和控制</p>
        </header>
        
        <div class="row">
            <c:forEach var="drone" items="${drones}">
                <div class="col-md-4">
                    <div class="card drone-card">
                        <div class="card-header">
                            <div class="d-flex justify-content-between align-items-center">
                                <h5 class="mb-0">${drone.model}</h5>
                                <c:choose>
                                    <c:when test="${drone.status == 'FLYING'}"><span class="badge bg-success status-badge">飞行中</span></c:when>
                                    <c:when test="${drone.status == 'RETURNING'}"><span class="badge bg-info status-badge">返航中</span></c:when>
                                    <c:when test="${drone.status == 'LANDING'}"><span class="badge bg-warning status-badge">降落中</span></c:when>
                                    <c:otherwise><span class="badge bg-secondary status-badge">待机</span></c:otherwise>
                                </c:choose>
                            </div>
                        </div>
                        <div class="card-body">
                            <p><strong>ID:</strong> ${drone.id}</p>
                            <p>
                                <strong>电池电量:</strong> ${drone.batteryLevel}%
                                <div class="progress battery-indicator">
                                    <c:choose>
                                        
                                    </c:choose>
                                </div>
                            </p>
                            <p><strong>坐标:</strong> ${drone.latitude}, ${drone.longitude}</p>
                            <p><strong>高度:</strong> ${drone.altitude} 米</p>
                            <a href="/drone/view/${drone.id}" class="btn btn-primary w-100">查看详情</a>
                        </div>
                    </div>
                </div>
            </c:forEach>
            
            <c:if test="${empty drones}">
                <div class="col-12">
                    <div class="alert alert-info text-center">
                        <h4>暂无无人机数据</h4>
                        <p>系统中还没有注册任何无人机</p>
                    </div>
                </div>
            </c:if>
        </div>
        
        <div class="text-center mt-4">
            <a href="/" class="btn btn-outline-primary">返回首页</a>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>